package com.ctsi.commons.util.async;

import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;

/**
 * 可监听的异步结果获取
 * 
 * @author yueming
 *
 * @param <V>
 */

public interface ListenableFuture<V> extends Future<V> {

	ListenableFuture<V> await() throws InterruptedException;

	void addListener(FutureListener<? extends ListenableFuture<? super V>> listener);

	Throwable cause();

	boolean await(long timeout, TimeUnit unit) throws InterruptedException;

	ListenableFuture<V> setFailure(Throwable cause);

	boolean tryFailure(Throwable cause);

	ListenableFuture<V> setSuccess(V result);

	boolean isSuccess();

	boolean setUncancellable();

	V getResult();
}
